#pragma once
#include "Runtime/Thread/Event.h"
namespace Alice
{
    struct RenderCommandFenceBundlerState
    {
        Event* mEvent;
        int32 RecursionDepth = 0;
    };
    void StartRenderCommandFenceBundler();
    void StopRenderCommandFenceBundler();
    class RenderCommandFence
    {
    public:
        enum class ESyncDepth
        {
            // The fence will be signalled by the render thread.
            RenderThread,

            // The fence will be enqueued to the RHI thread via a command on the immediate command list
            // and signalled once all prior parallel translation and submission is complete.
            RHIThread,

            // The fence will be signalled according to the rate of flips in the swapchain.
            // This is only supported on some platforms. On unsupported platforms, this behaves like RHIThread mode.
            Swapchain
        };
        Event* mEvent;
        RenderCommandFence();
        ~RenderCommandFence();
        void BeginFence(ESyncDepth SyncDepth = ESyncDepth::RenderThread);
        void Wait(bool bProcessGameThreadTasks = false) const;
    };
}